package game;

public class Task
{
	private int[] numbers;
	private String solution;
	public static final String NO_SOLUTION = "no solution";

	private static Solver solver = Solver.getInstance();

	/**
	 * Constructs for task.
	 * @param numbers numbers
	 */
	public Task(int... numbers)
	{
		this.numbers = new int[numbers.length];
		for (int i = 0; i < numbers.length; i++)
		{
			this.numbers[i] = numbers[i];
		}
	}
	
	/**
	 * Returns solution.
	 * @return solution.
	 */
	public String getSolution()
	{
		if (solution == null)
			solution = solver.gameSolve(numbers);
		return solution;
	}

	/**
	 * Returns numbers.
	 * @return numbers
	 */
	public int[] getNumbers()
	{
		return numbers;
	}

	/**
	 * Checks task is possible.
	 * @return true if it's possible
	 */
	public boolean isPossible()
	{
		return !getSolution().equals(NO_SOLUTION);
	}
}
